home *** CD-ROM | disk | FTP | other *** search
- Path: po.CWRU.Edu!lem
- From: lem@po.CWRU.Edu (Leonard E. Marinis)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: tcp/ip woes.
- Date: 7 Apr 1996 19:19:56 GMT
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Message-ID: <4k94gs$nm0@madeline.INS.CWRU.Edu>
- Reply-To: lem@po.CWRU.Edu (Leonard E. Marinis)
- NNTP-Posting-Host: christopher.ins.cwru.edu
-
-
- hi, i've been struggling with this questions
- for a few days now and was hoping to get some
- insight from the group here..
-
- currently i'm running linux 1.2.11, and in the
- process of completing my first tcp/ip oriented
- program. the program broadcasts a ping, then
- prints to screen the numeric and DNS entries
- of the replying hosts.. this is the piece of
- code that giving me headaches -
-
- /* check it out & process if ICMP_ECHOREPLY */
- mp=(struct icmphdr *)buff+20;
- if(!mp->type) {
- from_host=inet_ntoa(from.sin_addr);
- host_info=gethostbyaddr((char *)&from.sin_addr, sizeof(from.sin_addr), AF_INET);
- printf("\nreply from %s\t", from_host);
- if(strlen(from_host) < 13)
- printf("\t");
- printf("[%s]", host_info->h_name);
-
- } else
- printf("\nnon ICMP_ECHOREPLY packet");
-
- the strange thing is, it works fine. until about 80 host replies
- come in - at which time the process segmentation faults
- and quits. if i had any clue about how to analyze a core file, i would.
- (any suggestions where i could learn more about this?)
-
- anyhow, i've narrowed it down to the printf("[%s]", host_info->h_name);
- by process of elimination and use of commenting out code. the only thing
- i could possibly think is happening is that perhaps the replies are coming
- in too fast and overflowing a buffer of sorts i am not aware of.
-
- host_info, by the way, is declared as struct hostent *host_info;
- any help whatsoever would be appreciated. email responses would
- be ideal but i will check the group periodically as well.
- oh, and i'd be more than happy to furnish a full copy of the program per request.
- grazi,
- len marinis
- lem@po.cwru.edu
-
-
-